package com.archie.zhufengfm.adapters;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import com.archie.zhufengfm.fragments.home.BaseFragment;

import java.util.List;

/**
 * Created by Archie on 2015/10/20.
 */
public class CommonFragmentPagerAdapter extends FragmentPagerAdapter {

    private List<BaseFragment> fragments;

    public CommonFragmentPagerAdapter(FragmentManager fm, List<BaseFragment> fragments) {
        super(fm);

        this.fragments = fragments;
    }


    @Override
    public Fragment getItem(int position) {

        return fragments.get(position);
    }

    @Override
    public int getCount() {
        int ret = 0;

        if(fragments != null){
            ret = fragments.size();
        }

        return ret;
    }

    @Override
    public CharSequence getPageTitle(int position) {

        String ret = null;

        BaseFragment baseFragment = fragments.get(position);

        ret = baseFragment.getFragmentTitle();

        return ret;
    }
}
